/**
 *
 */
package com.angel.mocks.io.resourceLocation;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

/**
 * @author William
 *
 */
public class ResourceLocation {

	//public final static String BASE_RESOURCES_TEST_FILES = "/com/angel/io/test/resources/";
	public final static String BASE_RESOURCES_TEST_FILES = "/";

//	public final static String BASE_EXCEL_FILES = BASE_RESOURCES_TEST_FILES + "xls/";
//	public final static String BASE_PLAIN_TXT_FILES = BASE_RESOURCES_TEST_FILES + "txt/";

	public final static String BASE_EXCEL_FILES = BASE_RESOURCES_TEST_FILES;
	public final static String BASE_PLAIN_TXT_FILES = BASE_RESOURCES_TEST_FILES;

	public final static String TEST_EXCEL_FILE = BASE_EXCEL_FILES + "test.xls";

	public final static String HOTELES_EXCEL_FILE = BASE_EXCEL_FILES + "Hoteles - Ejemplo.xls";

	public final static Class<ResourceLocation> clazz = ResourceLocation.class;

	public static final String COUNTRIES_XLS_RESOURCE = BASE_EXCEL_FILES + "countries.xls";

	public static final String EXPEDIENTES_EXCEL_FILE = BASE_EXCEL_FILES + "expedientes.xls";

	public static final String MUNICIPALIDADES_EXCEL_FILE = BASE_EXCEL_FILES + "municipalidades.xls";;

	private ResourceLocation(){
		super();
	}

	public static InputStream findInputStreamFor(String fullPathFile) throws FileNotFoundException{
		String classPath = getSystemCurrentDirectory() + fullPathFile;
		File file = new File(classPath);
		InputStream inputStream = new FileInputStream(file);
		return inputStream;
	}

	public static File findFileFor(String fullPathFile){
		File file = new File(fullPathFile);
		return file;
	}

	private static final String getSystemCurrentDirectory(){
		String javaClassPath = System.getProperty("java.class.path");
		int pos = javaClassPath.indexOf(";");
		if(pos != -1){
			javaClassPath = javaClassPath.substring(0, pos);
		}
		return javaClassPath;
	}
}
